/*
 * Copyright (c) 2006-2020, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-05-21     chenhy       the first version
 */
#include "board.h"
#include "tim.h"
TIM_HandleTypeDef htim7;

int tim7_init(void)
{
  htim7.Instance = TIM7;
  htim7.Init.Period = 149;
  htim7.Init.Prescaler = 0;
  htim7.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim7.Init.AutoReloadPreload = TIM_AUTOMATICOUTPUT_ENABLE;
  HAL_TIM_Base_Init(&htim7);
  HAL_TIM_Base_Start(&htim7);
  return 0;
}
INIT_PREV_EXPORT(tim7_init);

void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
  if(htim->Instance == TIM7) {
    __HAL_RCC_TIM7_CLK_ENABLE();
  }
}

void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
{
  if(htim->Instance == TIM7) {
    __HAL_RCC_TIM7_CLK_DISABLE();
  }
}
